//
//  BaseTabBarController.m
//  MMairs
//
//  Created by dongguozheng on 2017/3/1.
//  Copyright © 2017年 dongguozheng. All rights reserved.
//

#import "BaseTabBarController.h"
#import "BaseNavViewController.h"
@interface BaseTabBarController ()
@property (nonatomic ,  strong)NSArray *tabbarNameArray;//tabbar名字
@property (nonatomic ,  strong)NSArray *tabbarImageArray;//tabbar图片
@end

@implementation BaseTabBarController
#pragma  mark---懒加载
-(NSArray *)tabbarNameArray
{
    if (!_tabbarNameArray) {
        _tabbarNameArray=@[@"设备", @"资讯", @"专家咨询", @"商城"];
    }
    return _tabbarNameArray;
}
-(NSArray *)tabbarImageArray
{
    if (!_tabbarImageArray) {
        _tabbarImageArray=@[@"ios-shebei", @"ios-zixun-w", @"ios-message-w", @"ios-mall-w"];
    }
    return _tabbarImageArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];

    [self  configViewControllers];
    
}
#pragma mark---加载控制器
-(void)configViewControllers
{
    NSMutableArray *array=[NSMutableArray arrayWithArray:@[@"EquipmentViewController",@"InformationViewController",@"MessageViewController",@"GoodsViewController"]];
    for (NSUInteger i=0; i<array.count; i++) {
        NSString *nameVC=array[i];
        UIViewController *vc=[[NSClassFromString(nameVC) alloc]init];
        BaseNavViewController *nav=[[BaseNavViewController alloc]initWithRootViewController:vc];
        nav.tabBarItem = [[UITabBarItem alloc]initWithTitle:self.tabbarNameArray[i] image:[self preventByDrawing:self.tabbarImageArray[i]] selectedImage:[self preventByDrawing:nil]];
        [array replaceObjectAtIndex:i withObject:nav];
    }
    self.viewControllers=array;
}
#pragma mark --- 防止图片被渲染
-(UIImage *)preventByDrawing:(NSString *)strImg{
    
    UIImage *loginImg = [UIImage imageNamed:strImg];
    loginImg = [loginImg imageWithRenderingMode:UIImageRenderingModeAutomatic];
    return loginImg;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
